<template>
	<view class="container">
		<top-back-navbar position="fixed" :title="title" background="#ffffff" color="#000000"></top-back-navbar>
		<view class="big_title f-w-700">资产数据</view>
		<!-- <view class="cz-box">
			<view class="cz-number">¥{{userInfo.credit2 || '0.00'}}</view> 
			<view class="cz-text">可用资金</view>
		</view> -->
		<view>
			<block v-for="(item,index) in res" :key="index">
				<view class="cz-list-cell" hover-class="uni-list-cell-hover">
					<view class="cz-triplex-list">
						<text class="cz-name">{{item.pay_info}}</text>
						<text class="cz-jine">{{item.money}}</text>
					</view>
					<view class="cz-triplex-list">
						<text class="cz-time">{{item.time}}</text>
						<text class="cz-num">{{item.charge_status}}</text>
					</view>
				</view>
			</block>
		</view>
		<view v-if="res.length == 0" style="padding-top: 300upx;">
			<image src="/static/searchlist.png" mode=""
				style="display: block;margin: 0 auto;width: 240upx;height: 240upx;"></image>
			<view style="text-align: center;color: #999;">暂时没有任何记录</view>
		</view>
		<!-- <uni-load-more v-if="load == 1" :loadingType="loadingType" :contentText="contentText"></uni-load-more> -->
	</view>
</template>

<script>
	import uniLoadMore from '../../components/uni-load-more.vue'
	export default {
		components: {
			uniLoadMore
		},
		data() {
			return {
				res: [],
				cointitle: ' ',
				page: 1,
				loadingType: 0,
				contentText: {
					contentdown: "上拉显示更多",
					contentrefresh: "正在加载...",
					contentnomore: "没有更多了"
				},
				systemInfo: {},
				load: 0,
				openid: '',
				userInfo: '',
				title: '',
				pageInfo: {
					'ccrl': {
						title: '抢宝活动',
						path: '/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=api.get_zc_list&app=1',
						query: {
							type:'credit2'
						}
					}, 
					'yzdp': {
						title: '预租店铺',
						path: '/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=api.get_zc_list&app=1',
						query: {
							type:'baht'
						}
					},
					'zzsy': {
						title: '转售收益',
						path: '/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=api.get_zc_list&app=1',
						query: {
							type:'baht'
						}
					},
					'jfmx': {
						title: '积分明细',
						path: '/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=api.get_zc_list&app=1',
						query: {
							type:'baht'
						}
					}
				}
			};
		},
		onLoad: function(e) {
			const type = e.type;
			this.pageType = type;
			this.title = this.pageInfo[type].title;
			uni.getStorage({
				key: 'openid',
				success: (res) => {
					this.openid = res.data
					this.setAjax()
				},
				fail: () => {
					uni.navigateTo({
						url: '../login/login'
					});
				}
			});
		},
		methods: {
			setAjax(flag=1) {
				var data = {
					...this.pageInfo[this.pageType].query,
					'openid': this.openid,
					'page':this.page
				}
				uni.request({
					url: this.$BASE_URL + this.pageInfo[this.pageType].path,
					method: 'POST',
					data: data,
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					success: res => {
						console.log(res)
						let list = [];
						if (this.pageType == 'kzkyzj') {
							list = Array.isArray(res.data.list) ? res.data.list : [];
							list.forEach(item => {
								item.pay_info = '矿铢资金';
								item.money = item.num;
								item.time = item.createtime;
								item.charge_status = item.remark;
							})
						}
						if (this.pageType == 'kzkysl') {
							list = Array.isArray(res.data.list) ? res.data.list : [];
							list.forEach(item => {
								item.pay_info = '矿铢数量';
								item.money = item.num;
								item.time = item.createtime;
								item.charge_status = item.remark;
							})
						}
						if(flag == 1){
							this.res = list;
						}
						
					},
					fail: () => {},
					complete: () => {}
				});
			}
		},
		onPullDownRefresh() {
			this.setAjax();
		},
		onReachBottom() {
			if (this.loadingType !== 0) {
				return;
			}
			this.loadingType = 1;
		},
	}
</script>

<style lang="scss">
	.status {
		width: 100%;
		font-size: 24upx;
		background: #e0e0e0;
		text-align: center;
		color: #fff;
		margin-top: 21upx;
	}

	page {
		background-color: #f2f5fa;
		box-sizing: border-box;
	}

	.container {
		padding: 0 30rpx 30rpx 30rpx;
		height: 100%;
	}

	.big_title {
		font-size: 32rpx;
		color: #1e1310;
		font-weight: 600;
		padding: 20rpx 30rpx 10rpx 0;
	}

	.cz-box {
		border-radius: 20rpx;
		padding: 30rpx;
		background: #001b4d;

		.cz-number {
			font-size: 46rpx;
			font-weight: bold;
			color: #fff;
			text-align: center;
		}

		.cz-text {
			font-size: 24rpx;
			font-weight: bold;
			color: #fff;
			text-align: center;
		}
	}

	.cz-list-cell {
		padding: 30rpx;
		border-radius: 20rpx;
		box-shadow: 0px 2px 8px 3px rgba(235,235,235,0.4);;
		padding: 20rpx 30rpx;
		margin-top: 30rpx;
		background-color: #fff;

		.cz-triplex-list {
			height: 50rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
		}

		.cz-name {
			font-size: 28rpx;
			font-weight: 600;
			color: #1e1310;
		}

		.cz-jine {
			font-size: 28rpx;
			font-weight: 600;
			color: #c30004;
		}

		.cz-time,
		.cz-num {
			font-size: 24rpx;
			color: #888889;
		}
	}
</style>
